package com.xnfh.home.viewmodel

import com.xnfh.framework.base.BaseViewModel
import com.xnfh.framework.bean.CropTypeBean
import com.xnfh.framework.bean.FieldDynamicsBean
import com.xnfh.framework.bean.PlanScheme
import com.xnfh.framework.bean.RespStateData
import com.xnfh.framework.log.LogUtil

/**
 * @Description:
 * @Author: ziheng
 * @CreateDate: 2024/1/5 13:48
 * @UpdateUser: ziheng
 * @UpdateDate: 2024/1/5 13:48
 * @UpdateRemark: 更新说明
 */
class ClubDetailViewModel : BaseViewModel() {
    private val viewModelRes = ClubDetailViewModelRes()
    val plantSchemeList = RespStateData<PlanScheme>()
    val fieldDynamicsBean = RespStateData<FieldDynamicsBean>()
    val cropTypeList = RespStateData<List<CropTypeBean>>()

    /**
     * 获取种植方案列表
     */
    fun requestPlanScheme(
        cropIds: String?,
        planName: String,
        pageNum: Int
    ) = launch {
        if(cropIds == null){
            LogUtil.e("requestPlanScheme: cropIds == null")
            return@launch
        }
        viewModelRes.requestPlantingScheme(cropIds,planName,pageNum,plantSchemeList)
    }

    /**
     * 田间动态
     */
    fun requestFieldMessage(
        cropId: Int?,
        provinceId: String?,
        cityId: String?,
        feedbackType: String?,
        page: Int
    ) = launch {
        viewModelRes.requestFieldMessage(cropId,provinceId,cityId,feedbackType,page,fieldDynamicsBean)
    }

    /**
     * 获取作物类型
     */
    fun requestCropType() = launch {
        viewModelRes.requestCropType(cropTypeList)
    }
}